//
//  NotiDetailViewController.m
//  tangshantongjiAPPFull
//
//  Created by yuntai on 2018/4/27.
//  Copyright © 2018年 yuntai. All rights reserved.
//

#import "NotiDetailViewController.h"

@interface NotiDetailViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (strong, nonatomic) UITableView *tableview;

@end

@implementation NotiDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"通知详情";
    UITableView *tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, kNavigationHeight, kScreenBoundWidth, kScreenBoundHeight-kNavigationHeight) style:UITableViewStylePlain];
    tableview.delegate = self;
    tableview.dataSource = self;
    
    tableview.estimatedRowHeight = 666;
    tableview.rowHeight = UITableViewAutomaticDimension;

    tableview.sectionHeaderHeight = 30;
    tableview.tableFooterView = [[UIView alloc]init];
    self.tableview = tableview;
    [self.view addSubview:tableview];
    [self.tableview reloadData];

}

#pragma mark - UITableViewDelegate,UITableViewDataSource

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return @"采价员信息";
    }else if (section == 1){
        return @"日期信息";
    }else{
        return @"内容信息";
    }
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return section==0 ? 2 :1 ;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *xiaojiacellId = @"XiaoJiaDetialCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:xiaojiacellId];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:xiaojiacellId];
        
        UILabel *nameLbel = [[UILabel alloc]init];
        nameLbel.textColor = kTextMiddleDarkColor;
        nameLbel.font = [UIFont systemFontOfSize:15];
        nameLbel.tag = 101;
        [cell.contentView addSubview:nameLbel];
    
        
        UILabel *detailLbel = [[UILabel alloc]init];
        detailLbel.numberOfLines = 0;
        detailLbel.tag = 102;
        detailLbel.textColor = kTextDeepDarkColor;
        detailLbel.font = [UIFont systemFontOfSize:15];
        [cell.contentView addSubview:detailLbel];
        
        [nameLbel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(cell.contentView.mas_left).offset(16);
            make.top.mas_equalTo(cell.contentView.mas_top).offset(8);
                make.width.mas_greaterThanOrEqualTo(25);
            
            
        }];
        [detailLbel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(nameLbel.mas_right).offset(8);
            make.top.mas_equalTo(cell.contentView.mas_top).offset(8);
            make.bottom.equalTo(cell.contentView.mas_bottom).offset(-8);
            make.right.mas_equalTo(cell.contentView.mas_right).offset(-10);

            
        }];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;


    }
    
    UILabel *nameLabel = [cell.contentView viewWithTag:101];
    UILabel *detailLabel = [cell.contentView viewWithTag:102];

    
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            nameLabel.text = @"姓名:";
            detailLabel.text = self.model.user_name;
        }else{
            nameLabel.text = @"联系电话:";
            detailLabel.text = self.model.phone;
        }
    }else if (indexPath.section == 1){
        nameLabel.text = @"日期:";
        detailLabel.text = self.model.time;

    }else{
        
        nameLabel.text = @"事项:";
        detailLabel.text = self.model.notice_desc;

    }
    
    return cell;
    
}

#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
    // 设置section字体颜色
    UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
    [header.textLabel setTextColor:kNavigationColor];
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}


@end
